/**
 * Created by M on 2017/7/6.
 */

function send_command(func_name, data, callback) {
    window[func_name](data, callback);
}

function RAIO_close() {
    window.external.exit();
}

//打开串口

var Rfidlib_callback;
function OpenRfidlibInfo(callback) {
    Rfidlib_callback = callback;
    window.external.OpenRFIDLIB("Rfidlib_getback");
}

function Rfidlib_getback(json) {
    Rfidlib_callback(json)
}


//开始读取
var ReadRfidlib_callback;
function ReadRFIDLIBInfo(data, callback) {
    ReadRfidlib_callback = callback;
    window.external.ReadRFIDLIB(data,"ReadRfidlib_getback");
}

function ReadRfidlib_getback(json) {
    ReadRfidlib_callback(json)
}


//关闭读取
var closeReadRfidlib_callback;
function closeReadRfidlibInfo(callback) {
    closeReadRfidlib_callback = callback;
    window.external.closeReadRfidlib("closeReadRfidlib_getback");
}

function closeReadRfidlib_getback(json) {
    closeReadRfidlib_callback(json)
}

//连接
var connectRfidlib_callback;
function connectRFIDLIBInfo(data, callback) {
    connectRfidlib_callback = callback;
    window.external.connectRfidlib(data,"connectRfidlib_getback");
}

function connectRfidlib_getback(json) {
    connectRfidlib_callback(json)
}

//关闭连接
var closeConnectRfidlib_callback;
function closeConnectRfidlibInfo(callback) {
    closeConnectRfidlib_callback = callback;
    window.external.closeConnectRfidlib("closeConnectRfidlib_getback");
}

function closeConnectRfidlib_getback(json) {
    closeConnectRfidlib_callback(json)
}

//写入AFI  data:写入的AFI
var RfidlibAFI_callback;
function RfidlibAFIInfo(data, uid,callback) {
    RfidlibAFI_callback = callback;
    window.external.WriteRfidlibAFI(data,uid,"RfidlibAFI_getback");
}

function RfidlibAFI_getback(json) {
    RfidlibAFI_callback(json)
}


//写入DSFID   data:写入的DSFID
var RfidlibDSFID_callback;
function RfidlibDSFIDInfo(data,uid, callback) {
    RfidlibDSFID_callback = callback;
    window.external.WriteRfidlibDSFID(data,uid,"RfidlibDSFID_getback");
}

function RfidlibDSFID_getback(json) {
    RfidlibDSFID_callback(json)
}



//打开EAS
var OpenRfidlibEAS_callback;
function OpenRfidlibEASInfo(data,callback) {
    OpenRfidlibEAS_callback = callback;
    window.external.openRfidlibEAS(data,"OpenRfidlibEAS_getback");
}

function OpenRfidlibEAS_getback(json) {
    OpenRfidlibEAS_callback(json)
}


//关闭EAS
var CloseRfidlibEAS_callback;
function CloseRfidlibEASInfo(data,callback) {
    CloseRfidlibEAS_callback = callback;
    window.external.closeRfidlibEAS(data,"CloseRfidlibEAS_getback");
}

function CloseRfidlibEAS_getback(json) {
    CloseRfidlibEAS_callback(json)
}


//关闭RFIDLIB
var CloseRfidlib_callback;
function CloseRfidlibInfo(callback) {
    CloseRfidlib_callback = callback;
    window.external.closeRfidlib("CloseRfidlib_getback");
}

function CloseRfidlib_getback(json) {
    CloseRfidlib_callback(json)
}
